﻿@model Retete.ViewModels.ReceptiiViewModel
@{ 
    ViewBag.Title = "Receptii"; 
}

<script type="text/javascript">
    function stergeInregistrare(id) {
        if (confirm("Doriti sa stergeti receptia selectata?") == true) {
            IDReceptieStearsa.value = id;
            form.submit();
        }
    }
</script>

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "form", name = "form" }))
{
    <table style="width: 100%">
        <tr>
            <td style="width: 190px; vertical-align: top; border-right-style: dashed; border-right-color: #CFCFCF; border-right-width: 1px;">
                <fieldset>
                    <legend>Activitati</legend>

                    <p class="toolbox">@Html.ActionLink("Adauga receptie", "Create")</p>
                </fieldset>

                <fieldset>
                    <legend>Selectare data</legend>

                    <p>@Html.Calendar(DateTime.Today.AddMonths(-1).Year, DateTime.Today.AddMonths(-1).Month, Model.SelectedDate)</p>
                    <p>@Html.Calendar(DateTime.Today.Year, DateTime.Today.Month, Model.SelectedDate)</p>
                </fieldset>
            </td>
            <td style="vertical-align: top;">
                @Html.ValidationSummary(false)
                @Html.HiddenFor(model => model.IDReceptieStearsa)

                <fieldset>
                    <legend>@Model.Titlu</legend>

                    <table class="grid">
                        <thead>
                            <tr>
                                <th style="width: 16px"></th>
                                <th style="width: 130px;">Receptie</th>
                                <th>Furnizor</th>
                                <th style="width: 80px;">Tva</th>
                                <th style="width: 139px;">Valoare</th>
                            </tr>
                        </thead>

                        <tbody>
                            @for (int i = 0; i < Model.Receptii.Count; i++)
                            {
                                <tr>
                                    <td>
                                        <img src="@Url.Content("~/Content/Images/Delete.png")" alt="Sterge" style="height: 12px; cursor: pointer;" onclick="stergeInregistrare(@Model.Receptii[i].ID)" />
                                        @Html.HiddenFor(element => element.Receptii[i].ID)
                                    </td>
                                    <td>@Html.ActionLink(Model.Receptii[i].Numar.ToString() + " din " + Model.Receptii[i].Data.ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), "Edit", new { id = Model.Receptii[i].ID })</td>
                                    <td>@Model.Receptii[i].FurnizorNume</td>
                                    <td>@Model.Receptii[i].Tva.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)</td>
                                    <td>@Model.Receptii[i].Valoare.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
}